<?php
//рус
class structure_admin_http_ajax extends controller_prototype_class
{
	private $_ctrl;
	
    protected function ControllerInit ()
    {
		$this->_ctrl = SysLoader::GetModule('admin', 'http', '_web', $this->User())->GetCtrl('structure'); 
    }

    public function update_sortPrAction ()
    {
        $result = $this->_ctrl->UpdateSort();
        $this->Response()->SetBody($result);
    }

    public function movePrAction ()
    {
        $result = $this->_ctrl->Move();
        $this->Response()->SetBody($result);
    }
    
    public function save_content_accessPrAction ()
    {
		$result = $this->_ctrl->SaveContentAccess();
        $this->Response()->SetBody($result);
    }
    
    public function media_add_structurePrAction()
    {
        $obj = SysLoader::GetModResponse();

        $baseUrlParams = array(
        						'module' => 'admin',
        						'ctrl' => $this->GetSelfName(), 
        						'action' => 'media_add_structure', 
        						'cat' => $this->_ctrl->_cid, 
        						'subcat' => $this->_ctrl->_subCat
        					);       
        
		$obj->SetStatus(MR_STATUS_OK);
		$obj->result = $this->_ctrls->media->OutMediaFilesBlock($baseUrlParams, array('contentButton' => true));

        $this->Response()->SetBody($obj);  	
    }  

    public function get_module_params_blockPrAction()
    {
    	$obj = SysLoader::GetModResponse();
    	
      	if ($this->_ctrl->_subCat)
      	{
      		$elementObj = $this->_ctrl->_structMapper->GetById($this->_ctrl->_subCat);      
        
        	$pageType = intval($this->Request()->get('page_type'));
        	$elementObj->SetPageType($pageType);

			$obj->SetStatus(MR_STATUS_OK);
			$obj->result = $this->_ctrl->getModuleParamsBlock($elementObj->GetModuleParams());
      	}
      	else
      	{
      		$obj->SetStatus(MR_STATUS_ERROR);
      		$obj->SetMessage('Раздел не найден');
      	}
			
        $this->Response()->SetBody($obj);     	
    }
}